<?php
$modifyPasswordStr = Yii::t('BWeSport', 'modify password');
$oldPasswordStr = Yii::t('BWeSport', 'old password');
$cancelModifyStr = Yii::t('BWeSport', 'cancel modify');
$changePasswordStr = Yii::t('BWeSport', 'change password');
$newPasswordStr = Yii::t('BWeSport', 'new password');
$repeatNewPasswordStr = Yii::t('BWeSport', 'repeat new password');
$repeatInputNewPasswordStr = Yii::t('BWeSport', 'repeat input new password');

?>
<style>
    .form-signin {
        max-width: 330px;
        padding: 15px;
        margin: 0 auto;
    }
    .form-signin .form-signin-heading,
    .form-signin .checkbox {
        margin-bottom: 10px;
    }
    .form-signin .checkbox {
        font-weight: normal;
    }
    .form-signin .form-control {
        position: relative;
        height: auto;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px;
    }
    .form-signin .form-control:focus {
        z-index: 2;
    }
    .form-signin input[type="email"] {
        margin-bottom: -1px;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
    }
    .form-signin input[type="password"] {
        margin-bottom: 10px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
</style>
<?php
$user = Blyn::app()->getCurrentUser();
$attributes = $user->getAttributes();

$model = new BDynamicFormModel();
$passwordField = 'media_password_userPassword';
$password1Field = 'media_password1_userPassword';
$password2Field = 'media_password2_userPassword';

$model->addField($passwordField);
$model->addField($password1Field);
$model->addField($password2Field);
?>


<div class="container">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        "id" => "manage-password-form",
        'enableAjaxValidation' => FALSE,
        'htmlOptions' => array('class' => 'form-signin', 'role' => 'form'),
    ));
    ?>
    <h3 class="form-signin-heading text-muted"><?php echo $modifyPasswordStr;?></h3>
    <?php
    if (isset($isChangedPassword)) {
        if ($isChangedPassword == 'fail') {
            ?>
            <p class="bg-warning">
                <strong>opps....Fail to change password.</strong>
            </p>
            <?php
        }
        if ($isChangedPassword == 'success') {
            ?>
            <p class="bg-success">
                <strong>Yeah, Change password is done.</strong>
            </p>
        <?php
        }
    }
    ?>
    <?php
    echo CHtml::label($oldPasswordStr.':', 'password');
    echo CHtml::activeTextField($model, $passwordField, array(
        'class' => 'form-control',
        'placeholder' => $oldPasswordStr.'...', 'required' => 'true', 'autofocus' => 'true'));
    echo CHtml::label($newPasswordStr.':', 'password');
    echo CHtml::activeTextField($model, $password1Field, array(
        'class' => 'form-control',
        'placeholder' => $newPasswordStr.'...',
        'required' => 'true'));
    echo CHtml::label($repeatNewPasswordStr.':', 'password');
    echo CHtml::activeTextField($model, $password2Field, array(
        'class' => 'form-control',
        'placeholder' => $repeatInputNewPasswordStr.'...',
        'required' => 'true'));
    ?>
    <label></label>
    <?php
    echo $control->getAjaxLink(
            array('name' => $changePasswordStr, 'id' => 'saveUserPassword'), array(
        'htmlOptions' => array(
            'class' => 'btn btn-primary btn-lg btn-block')));
    ?>
    <?php
    echo $control->getAjaxLink(
            array('name' => $cancelModifyStr, 'id' => 'displayUserInfo'), array(
        'htmlOptions' => array(
            'class' => 'btn btn-info btn-lg btn-block')));
    ?>
<?php $this->endWidget(); ?>
</div>